import type { App } from "vue";
import * as ElementPlusIconsVue from "@element-plus/icons-vue";
import * as CarbonIconsVue from "@vicons/carbon";
import Vue3Marquee from "vue3-marquee";

import OpenTime from "@/components/open-time.vue";
import UploadImg from "@/components/upload-img.vue";
import SystemImg from "@/components/system-img.vue";
import Avatar from "@/components/avatar.vue";
import MultipleSelect from "@/components/multiple-select.vue";
import GameListAside from "@/components/game-list-aside.vue";
import GlobalSound from "@/components/global-sound.vue";

import UiAmount from "@/components/ui/amount.vue";
import UiEmpty from "@/components/ui/empty.vue";
import UiPagination from "@/components/ui/pagination.vue";

/**
 * 全局注册自定义组件
 * @param app
 */
export function setupComponents(app: App) {
  app.use(Vue3Marquee);
  // 注册elementplus图标
  for (const [key, component] of Object.entries(ElementPlusIconsVue)) {
    app.component(key, component);
  }
  // 注册carbon图标
  for (const [key, component] of Object.entries(CarbonIconsVue)) {
    app.component(`Car${key}`, component);
  }
  app.component(`open-time`, OpenTime);
  app.component(`upload-img`, UploadImg);
  app.component(`system-img`, SystemImg);
  app.component(`avatar`, Avatar);
  app.component(`multiple-select`, MultipleSelect);
  app.component(`game-list-aside`, GameListAside);
  app.component(`global-sound`, GlobalSound);
  app.component(`ui-amount`, UiAmount);
  app.component(`ui-empty`, UiEmpty);
  app.component(`ui-pagination`, UiPagination);
}
